package dao;

import java.util.ArrayList;

import org.hibernate.Session;

import commande.Article;
import commande.Commande;
import commande.LigneCommande;


public class DaoLigneCommandeHBN extends DAOHibernate implements
		DaoLigneCommande {

	@Override
	public LigneCommande get(int numero) {
		try {
			Session session = connect();
			LigneCommande ligne = (LigneCommande)session.get(LigneCommande.class,numero);
			close(session);
			return ligne;
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public ArrayList<LigneCommande> load(Commande commande) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void save(LigneCommande ligne) {
		// TODO Auto-generated method stub
		try {
			Session session = connect();
			session.save(ligne);
			close(session);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	@Override
	public void saveOrUpdate(LigneCommande ligne) {
		// TODO Auto-generated method stub
		try {
			Session session = connect();
			session.saveOrUpdate(ligne);
			close(session);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

	}

	@Override
	public void remove(LigneCommande ligne) {
		// TODO Auto-generated method stub
		try {
			Session session = connect();
			session.delete(ligne);
			close(session);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

	}

}
